<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, minimal-ui">
<title>投票详情页</title>
<link rel="stylesheet" href="layui/css/layui.css">
<link rel="stylesheet" href="vendor/swiper/swiper.min.css">
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet"> 
</head>
<body>
	
<!-- Overlay panel -->
<div class="body-overlay"></div>
<!-- Left panel -->
<div id="panel-left"></div>
<!-- Right panel -->
<div id="panel-right"></div>


<div class="page page--main" data-page="blog">
	
	<!-- PAGE CONTENT -->
	<div class="page__content page__content--with-header">
		<div class="page__title-bar">
			<h3>候 选 人 : ( 该奖项允许选择 <strong id="size" style="color: red"></strong> 位 )</h3>
		</div>
              <div class="cards cards--12" id="loadlist-blog">

              </div>
	      <div class="buttons buttons--centered mb-20">
			  <input autocomplete="off" type="text" id="prizeNum_check" name="prizeNum_check" style="display: none;"/>
			  <input autocomplete="off" type="text" id="size_check" name="size_check" style="display: none;"/>
			<div id="subBtn" class="button button--more">提 交 我 的 选 择</div>
<!--			<div id="showLess" class="button button&#45;&#45;disabled">No more posts</div> -->
	      </div>
	
	</div>
			  

</div>
<!-- PAGE END -->


<!-- Social Icons Popup -->
<div id="popup-social"></div>
 
<!-- Alert --> 
<div id="popup-alert"></div>  

<!-- Notifications --> 
<div id="popup-notifications"></div>  

<script src="vendor/jquery/jquery-3.5.1.min.js"></script>
<script src="vendor/jquery/jquery.validate.min.js" ></script>
<script src="vendor/swiper/swiper.min.js"></script>
<script src="js/swiper-init.js"></script>
<script src="layui/layui.js"></script>
<script src="js/jquery.custom.js"></script>
<script src="../static/js/check.js"></script>
<script>
	var layer = layui.layer;

	//提交方法
	$('#subBtn').click(function () {
		//允许选择个数
		var size=$('#size_check').val()
		//当前奖项编号
		var num=$('#prizeNum_check').val()
		//当前投票用户
		var userName=sessionStorage.getItem('userName')
		//当前投票用户工号
		var ghid=sessionStorage.getItem('workerNo')
		//当前投票用户sfz
		var sfz=sessionStorage.getItem('sfz')
		//获取checkbox的值
		var arr = [];
		$("input:checkbox[name='like']:checked").each(function(i){
			arr[i] = $(this).val();
		});
		//选择个数判断
		if(arr.length>size){
			layer.msg("当前奖项只允许选择 "+size+" 个！您选择了 "+arr.length+" 个！")
		}else if(arr.length==0){
			layer.msg("请至少选择一位提交！")
		} else{
			let confirm1=layer.confirm("当前奖项允许选择 "+size+" 个，您选择了 "+arr.length+" 个。</br>" +
					"确认提交吗？",{
				btn: ['确认提交','再想想'],
				title: '确认选择'
			},function () {
				$.ajax({
					url: '' + '/vote-info/addVote',
					method: 'POST',
					contentType: 'application/json',
					data: JSON.stringify({
						userName:userName,
						ghid:ghid,
						prizeNum:num,
						voteNomineeIds:arr,
						sfz:sfz
					}),
					success: function(res) {
						parent.layer.closeAll('iframe');
						parent.searchPrize()
						//弹出提示消息
						parent.layer.msg(res.msg)
					}
				})
				layer.close(confirm1);
			},function (){
				layer.close(confirm1);
			})
		}
	})
</script>
</body>
</html>